<extend name="Base/user"/>

<block name="breadcrumb">
  <ul class="breadcrumb">
    <li><a href="{:U('/')}">首页</a></li>
    <li><a href="{:U('Member/Order')}">我的订单</a></li>
    <li class="active">订单详情</li>
  </ul>
</block>

<block name="body">
  <div class="user-box">
    <h3>订单详情</h3>
    
    <div class="box-bd">
      <div class="order-detail-tables">
        <volist name="data.store_list.store" id="vo">
          <table class="order-detail-table">
            <!--{//订单号展示}-->
            <thead>
              <tr>
                <th class="column-info" colspan="7">
                  <div class="column-content">商品来源店铺：{:get_store_text($key)}               
                  </div>
                </th>
              </tr>
            </thead>
            <php>$store_info = $data['store_list']['delivery'][$key];$ship_info = $data['store_list']['Ship'][$key];</php>
            <tbody>
              <!--{//店铺商品展示start}-->
                <volist name="vo" id="vl" key="k">
                  <php>$rows = count($vo);</php>
                  <tr>
                    <td class="column-detail">
                      <ul class="order-goods-list">                  
                          <li <eq name="k" value="0">class="first"</eq>>
                            <a href="{:U('Item/detail', array('id' => $vl['item_id']))}" class="pic" target="_blank"><img src="__ROOT__{:get_image_thumb($vl['cover_path'], 60, 60)}" width="60" class="goods-thumb" alt="{$vl.name}"></a>
                            <h5><a target="_blank" href="{:U('Item/detail', array('id' => $vl['item_id']))}" class="goods-name">{$vl.name}</a><if condition="$vl[price] eq 0"><span class="text-danger">（赠品）</span></if></h5>
                            <span class="color-999">{:custom_unserialize($vl['spec'], 1, '，')}</span>
                          </li>
                      </ul>
                    </td>
                    <td width="100" class="text-center">
                      <span class="text-danger">&yen; {$vl.price}</span>
                      <gt name="vl.fugou_dis_price" value="0">
                        <span class="price-tip">老客户立减</span>
                      </gt>
                    </td>
                    <td width="100" class="text-center color-999">
                      <i class="icon icon-close"></i> {$vl.quantity}
                      <if condition="$vl['memo']">
                        <br />({$vl.memo})
                      </if>
                    </td>
                    
                    <if condition="$store_info.o_status eq 202">
                      <td width="150" class="text-center">
                      <notempty name="vl.is_comment">
                        <a href="javascript:comment.detail({$data.uid}, {$vl.item_id},{$data['id']});" class="btn btn-sm btn-default">评价详情</a>
                      <else/>
                        <a href="javascript:comment.add({$vl.item_id},{$vl.store_id},{$data['id']});" class="btn btn-sm btn-positive">立即评价</a>
                      </notempty>
                    </td>
                    </if>
                  
                    <if condition="$k eq 1">
                      <td class="column-action" rowspan="{$rows}">
                        <em class="msg">{$store_info.o_status|get_order_status_text}</em>
                        <div class="text-center order-info order-action">
                          <switch name="store_info.o_status">
                            <case value="201">
                              <a href="javascript:order.confirm({$store_info['id']});" class="btn btn-sm btn-positive">确认收货</a>
                              <a class="btn btn-sm" href="javascript:order.refund({$store_info['id']});">申请售后</a>
                            </case>
                            <case value="301">
                              <a href="javascript:$.ui.load('{:U('Order/reShip',array('order_id' => $store_info['id']))}','退货信息');" class="btn btn-sm">立即退货</a>
                            </case>
                            <case value="302">
                              <a class="btn-sm" href="javascript:$.ui.load('{:U('Order/reShip',array('order_id' => $store_info['id']))}','退货物流信息');">退货物流</a>
                            </case>
                            <case value="0">
                                <!-- <a href="{:U('Order/preview', array('order_sn' => $data['order_sn']))}" class="btn btn-sm btn-positive"><i class="icon icon-recharge"></i> 立即支付</a> -->
                                <!-- <a href="javascript:order.setStatus({$store_info['id']}, 'cancel');" class="btn btn-sm btn-default" id="cancleBtn" title="取消订单"><i class="icon icon-round-close"></i> 取消订单</a> -->
                            </case>
                          </switch>
                          <switch name="store_info.o_status">
                            <case value="201|202">
                            <empty name='store_info.refuse_message' >
                              <a href="javascript:$.ui.load('{:U('Order/getDelivery?order_id='.$store_info['id'])}', '物流配送信息');" class="btn btn-sm">查看物流</a>
                            </empty>
                            </case>
                            <case value="202">
                             <empty name='store_info.refuse_message' >
                              <if condition="$store_info.complete_time gt time()-C('MAX_REFUND_CASH_DAY')*24*3600">
                                <a  class="btn btn-sm" href="javascript:order.refund({$store_info['id']});">申请售后</a>
                              </if>
                              </empty>
                            </case>
                            <case value="300">
                              <a class="btn btn-sm" href="javascript:order.unrefund({$store_info['id']});">撤销售后申请</a>
                            </case>
                            <case value="405">
                              <a  class="btn btn-sm" href="javascript:order.refund({$store_info['id']});">申请售后</a>
                              <if condition="($store_info['complete_time'] eq 0) AND ($store_info['shipping_time'] gt 0)">
                                <a href="javascript:order.confirm({$store_info['id']});" class="btn btn-sm btn-positive">确认收货</a>
                              </if>
                            </case>
                          </switch>
                        </div>
                      </td>
                    </if>

                  </tr>
                </volist>
              <!--{//店铺商品展示end}-->

              <!--{//订单状态信息展示start}-->
                <tr>
                  <td class="column-delivery" colspan="7">
                    <div class="order-delivery-status">
                      <ol class="order-delivery-steps clearfix">
                        <li class="step step-first step-now">
                          <div class="progress">
                            <span class="text">下单</span>
                          </div>
                          <div class="info">{$store_info.create_time|time_format}</div>
                        </li>
                        <li class="step <gt name="store_info.o_status" value="0">step-now</gt>">
                          <div class="progress"><span class="text">付款</span></div>
                          <gt name="store_info.o_status" value="0"><div class="info">{$store_info.payment_time|time_format}</div></gt>
                        </li>
                        <li class="step <gt name="store_info.o_status" value="0">step-now</gt>">
                          <div class="progress"><span class="text">配货</span></div>
                          <gt name="store_info.o_status" value="0"><div class="info">{$store_info.payment_time|time_format}</div></gt>
                        </li>
                        <li class="step <gt name="store_info.shipping_time" value="0">step-now</gt>">
                          <div class="progress"><span class="text">出库</span></div>
                          <gt name="store_info.shipping_time" value="0"><div class="info">{$store_info.shipping_time|time_format}</div></gt>
                        </li>
                        <switch name="store_info.o_status">
                          <case value="300|301|302|304">
                           <li class="step step-last step-now">
                              <div class="progress"><span class="text">退款中</span></div>
                            </li>
                          </case>
                          <case value="303">
                            <li class="step step-last step-now">
                              <div class="progress"><span class="text">已退款</span></div>
                            </li>
                          </case>
                          <case value="404">
                            <li class="step step-last step-now">
                              <div class="progress"><span class="text">订单取消</span></div>
                            </li>
                          </case>
                          <case value="405">
                            <li class="step step-last <if condition="($store_info['complete_time'] eq 0) AND ($store_info['shipping_time'] gt 0)">step-now</if>">
                              <div class="progress"><span class="text">交易成功</span></div>
                            </li>
                          </case>
                        </switch>
                        <lt name="store_info.o_status" value="300">
                          <li class="step step-last <eq name="store_info.o_status" value="202">step-now</eq>">
                            <div class="progress"><span class="text">交易成功</span></div>
                            <eq name="store_info.o_status" value="202"><div class="info">{$store_info.complete_time|time_format}</div></eq>
                          </li>
                        </lt>
                      </ol>
                    </div>
                  </td>
                </tr>
              <!--{//订单状态信息展示end}-->
            </tbody>
          </table>
        </volist>
      </div>
      <div class="order-detail-total clearfix">
        
        <dl class="total-list">
          <dt>商品总价：</dt>
          <dd>&yen; {$data.total_price}</dd>
          <dt>+ 运费总额：</dt>
          <dd>&yen; {$data.delivery_fee}</dd>
          <gt name="data.payment.coupon_amount" value="0">
            <dt>- 优惠券抵扣：</dt>
            <dd>&yen; {$data.payment.coupon_amount}</dd>
          </gt>
          <gt name="data.payment.card_amount" value="0">
            <dt>- 礼品卡抵扣：</dt>
            <dd>&yen; {$data.payment.card_amount}</dd>
          </gt>
          <gt name="data.payment.score_amount" value="0">
            <dt>- 积分抵扣：</dt>
            <dd>&yen; {$data.payment.score_amount}</dd>
          </gt>
          <gt name="data.payment.manjian" value="0">
            <dt>- 满减优惠：</dt>
            <dd>&yen; {$data.payment.manjian}</dd>
          </gt>
          <if condition="$data['discount_amount'] gt 0">
            <dt>- 优惠金额：</dt>
            <dd>&yen; {$data.discount_amount}</dd>
          </if>
          <php>$amount = $data['finance_amount'] + $data['total_amount'];</php>
          <if condition="$data['payment_time'] gt 0">
            <dt>实际支付：</dt>
            <dd class="text-price">{:sprintf('%.2f', $amount)}</dd>
            <gt name="amount" value="0">
            <p class="amount-info">
              ( <if condition="$data['finance_amount'] gt 0">余额：{$data.finance_amount} 元</if>
              <if condition="$data['finance_amount'] gt 0 AND $data['total_amount'] gt 0">+</if>
              <gt name="data.total_amount" value="0">
                {$data.payment.payment_type|get_payment_type_text}：{$data.total_amount}</b> 元
              </gt>
              )
            </p>
            </gt>
            <else />
            <dt>还需支付金额：</dt>
            <dd class="text-price">{:sprintf('%.2f', $amount)}</dd>
            <gt name="amount" value="0">
              <p class="amount-info">
                （<if condition="$data['finance_amount'] gt 0">余额：{$data.finance_amount} 元</if>
                <if condition="$data['finance_amount'] gt 0 AND $data['total_amount'] gt 0">+</if>
                <gt name="data.total_amount" value="0">
                  第三方支付：{$data.total_amount}</b> 元
                </gt>）
              </p>
            </gt>
          </if>
          <eq name="data.o_status" value="0">
           <dt>
            <a href="{:U('Order/preview', array('order_sn' => $data['order_sn']))}" class="btn btn-sm btn-positive"> 立即支付</a>
           </dt>
           <dd>
            <a href="javascript:order.setStatus({$data['id']}, 'cancel');" class="btn btn-sm btn-default" id="cancleBtn" title="取消订单"> 取消订单</a>
           </dd>
          </eq>
        </dl>
      </div>
    </div>

    <div class="order-delivery-address">
      <div id="changeAddress" class="order-text-section">
        
        <h4>订单信息</h4>
        <table class="order-text-table">
          <tbody>
            <tr>
              <th>订&nbsp;单&nbsp;号：</th>
              <td>{$data.order_sn}</td>
            </tr>
            <tr>
              <th>下单时间：</th>
              <td>{$data['create_time']|time_format}</td>
            </tr>
            <tr>
              <th>合&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;计：</th>
              <td>{:count($data['store_list']['store'])}个包裹 {$data['total_quantity']} 件商品</td>
            </tr>
          </tbody>
        </table>

        <h4>收货信息 </h4>
        <table class="order-text-table">
          <tbody>
            <tr>
              <th>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</th>
              <td>{$data.ship.ship_uname}</td>
            </tr>
            <tr>
              <th>联系电话：</th>
              <td>{$data.ship.ship_mobile}</td>
            </tr>
            <tr>
              <th>收货地址：</th>
              <td>{$data.ship.ship_area}, {$data.ship.ship_address}</td>
            </tr>
          </tbody>
        </table>
        <notempty name='data.memo'>

        <h4>订单备注 </h4>
        <table class="order-text-table">
          <tbody>
              <tr>
              <volist name='data.memo' id='vo'>
              <th>备注（{$key}）：</th>
              <td>{$vo}</td>
              </volist>
            </tr>
          </tbody>
        </table>

        </notempty>
        <notempty name='data.invoice_des'>
     
        <h4>发票信息 </h4>
        <table class="order-text-table">
          <tbody>
            <volist name='data.invoice_des' id='vo'>
              <tr>
              <th>{$key}：</th>
              <td>{$vo}</td>
            </tr>
            </volist>
          </tbody>
        </table>
    
        </notempty>
        <notempty name='data.realname'>
     
        <h4>实名信息备案 </h4>
        <table class="order-text-table">
          <tbody>
              <tr>
              <th>真实姓名：</th>
              <td>{$data.realname}</td>
              </tr>
              <tr>
              <th>身份证号：</th>
              <td>{$data.idcard}</td>
              </tr>
          </tbody>
        </table>
    
        </notempty>
      </div>   
      <div class="order-text-section"></div>
    </div>
  </div>
</block>
<block name="script">
  <script>
    var order, comment;
    seajs.use(['order', 'comment', 'delivery'], function(o, c, delivery){
      order = o;
      comment = c;
      //delivery.getDeliveryInfo("{$data.Ship.delivery_name}", "{$data.Ship.delivery_sn}");
    });
  </script>
</block>